/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package satk.database;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import satk.beans.interfaces.IntControlManagerDB;
import satk.objetos.Peso;

/**
 * <h3>ManagerPeso.java</h3>
 * <div><em>Fecha de creación: 15/05/2011, 10:16:11 PM.</em></div>
 * <p></p>
 * @author Sergio Flores Genis <sf.cancun@gmail.com>
 */
public class ManagerPeso extends DBManager
        implements IntControlManagerDB<Peso> {

    private boolean externalCnn = false;

    public ManagerPeso(Connection c) {
        super(c);
        this.externalCnn = true;
    }

    public ManagerPeso() {
        super();
    }

    public List<Peso> findPeso(String name, int limit) {
        List<Peso> list = new LinkedList<Peso>();
        try {
            ResultSet r = find("c_peso", "desc_peso", name, limit);
            while (r.next()) {
                int identificador = r.getInt("idc_peso");
                String peso = r.getString("desc_peso");
                Peso p = new Peso(identificador, peso);
                list.add(p);
            }
        } catch (SQLException ex) {
            Logger.getLogger(ManagerCategoria.class.getName()).log(Level.SEVERE,
                    "Error al buscar la categorias", ex);
        } catch (Exception ex) {
            Logger.getLogger(ManagerCategoria.class.getName()).log(Level.WARNING,
                    "Exepcion desconosida", ex);
        } finally {
            if (!externalCnn) {
                closeConexion();
            }
        }
        return list;
    }

    @Override
    public int add(Peso o) throws SQLException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Peso getById(long id) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public List<Peso> getAll() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public int update(Peso o, Peso n) throws SQLException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public int remove(Peso o) throws SQLException {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
